import 'package:flutter/material.dart';
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:webview_flutter/webview_flutter.dart';

class LineCharts extends StatefulWidget {
  @override
  _LineChartsState createState() => _LineChartsState();
}

class _LineChartsState extends State<LineCharts> {

  @override
  Widget build(BuildContext context) {
    
    return FutureBuilder(
      future: fetchHtmlString(),
        builder: (context,snapshot){
          String str = Uri.dataFromString(snapshot.data, mimeType: 'text/html', encoding: Encoding.getByName('utf-8')).toString();
          return Container(
          child: WebView(
            javascriptMode: JavascriptMode.unrestricted,
            onWebViewCreated: (WebViewController controller) {
              controller.loadUrl(str);
            },
          ),
        );
      },
    );

  }

  Future fetchHtmlString() async {
    String filePath = 'lib/common/views/charts/lineChart.html';
    String fileHtmlContents = await rootBundle.loadString(filePath);
    return  fileHtmlContents;
  }
  
}